<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>修改密码--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="format-detection" content="telephone=no"/>
    <link href="/resource/css/index.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="/resource/common/layui/css/layui.css" media="all"/>
</head>
<style>
    .main #test5 {
        margin-top: 20px;
        margin-left: 40px;
    }
</style>
<body class="index">

<div class="layui-form" style="margin:auto;margin-top:10px">
    <div class="top">
        <div class="main">
            <div id="test5"></div>
            <div id="contentMain" style="width: 550px;margin-top: 20px;margin-left: 40px">
                <textarea id="editor" class=" layui-textarea" name="content" style="height: 200px"></textarea>
            </div>
        </div>
        <div class="notice_bot">
            <div class="r_right but_p">
                <button class="but_save layui-btn" lay-submit="" lay-filter="Submit" style="padding: 0">提交
                </button>
                <button class="but_close" onclick="Cancel()">关闭</button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/resource/common/layui/layui.js"></script>
<script type="text/javascript" th:inline="javascript">


    layui.use(['table', 'layer', 'upload', 'rate', 'form', 'layedit'], function () {
        var table = layui.table,
            $ = layui.$,
            layer = layui.layer,
            rate = layui.rate,
            layedit = layui.layedit,
            upload = layui.upload,
            form = layui.form;
        Cancel = function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        }
        var orderId = [[${orderId}]]
        var score = 3;
        rate.render({
            elem: '#test5'
            , value: 3
            , text: true
            , setText: function (value) { //自定义文本的回调
                var arrs = {
                    '1': '极差'
                    , '2': '差'
                    , '3': '中等'
                    , '4': '好'
                    , '5': '极好'
                };
                this.span.text(arrs[value] || (value + "星"));
            }
            , choose: function (value) {
                score = value;
            }
        })
        layedit.set({
            //暴露layupload参数设置接口 --详细查看layupload参数说明
            uploadImage: {
                url: '/layeditUpload.do',
                accept: 'image',
                acceptMime: 'image/*',
                exts: 'jpg|png|gif|bmp|jpeg',
                size: '10240'
            }
            , uploadVideo: {
                url: '/layeditUpload.do',
                accept: 'video',
                acceptMime: 'video/*',
                exts: 'mp4|flv|avi|rm|rmvb',
                size: '20480'
            }
            //右键删除图片/视频时的回调参数，post到后台删除服务器文件等操作，
            //传递参数：
            //图片： imgpath --图片路径
            //视频： filepath --视频路径 imgpath --封面路径
            , calldel: {
                url: '/Attachment/DeleteFile'
            }
            //开发者模式 --默认为false
            , devmode: true
            //插入代码设置
            , codeConfig: {
                hide: true,  //是否显示编码语言选择框
                default: 'javascript' //hide为true时的默认语言格式
            }
            , tool: [
                'code', 'strong', 'italic', 'underline', 'del', 'addhr', 'fontFomatt', 'face'
                , 'left', 'center', 'right', 'link', 'unlink', 'images', 'image_alt', 'video', 'anchors'
                , 'table', 'fullScreen']

        });
        var index = layedit.build('editor', {
            height: 300 //设置编辑器高度
        });
        form.on('submit(Submit)', function (data) {
            data.field.score = score
            data.field.orderId = orderId
            data.field.content = layedit.getContent(index)
            $.ajax({
                url: '/front/addEvaluate.do',
                type: 'post',
                data: data.field,
                dataType: 'json',
                async: false,
                success: function (result) {
                    if (!result.status) {
                        parent.layer.msg(result.msg, {time: 2000});
                        return false;
                    } else {
                        parent.layer.msg("评价成功!", {time: 1000});
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                        parent.layui.table.reload('house-user-order', {});
                    }
                }

            });
        });
    });

</script>

</body>
</html>